package lab03;




import java.io.*;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;

public class Test07 {
    public static void main(String[] args) throws IOException {
        File file = new File("E:\\test (2).zip");

        ZipFile zipFile = new ZipFile(file);

        //Enumeration枚举
        Enumeration entries = zipFile.entries();

        ZipEntry zipEntry = null;


        //创建文件夹
        File dir = new File("E:\\test");

           dir.mkdir();
        //读文件


        InputStream fileInputStream = zipFile.getInputStream(zipEntry);
        String newFileName = "E:\\" + zipEntry.getName();

        File newFile = new File(newFileName);

        if (!newFile.exists()) {
            newFile.createNewFile();
        }

        System.out.println(zipEntry.getName());

        FileOutputStream fileOutputStream = new FileOutputStream(new File("E:\\test02"));

        byte[] data = new byte[1024];

        while ((fileInputStream.read(data)) != -1) {

            fileOutputStream.write(data);
        }

        fileInputStream.close();
        fileOutputStream.close();
        //写文件
    }
}













